/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package replica.transaction;

import generalResourceLalla.TaskList;
import java.util.List;

/**
 *
 * @author andrea
 */
public class TransactionGetListMsg extends TransactionStatus
{
    //private Long serial;
    //private TaskList taskList;
    
    
    public TransactionGetListMsg(long nodeId,Long serial, Type type,Long replicaHostId,TaskList taskList)
    {
        
        super(nodeId, serial,Operation.buildGetListOperation(nodeId),type, replicaHostId,taskList);
    }
    
    public static TransactionGetListMsg build_GETLIST_REQ_msg(long nodeId)
    {
        return new TransactionGetListMsg(nodeId,null,TransactionStatus.Type.GETLIST_REQ,
                null,null);
    }
    
    public static TransactionStatus build_MYSERIAL_msg(long nodeId,Long replicaHostId,Long serial)
    {
        return new TransactionStatus(nodeId, serial,null,Type.MYSERIAL,replicaHostId,null, null);
                
    }
    
    public static TransactionStatus build_IWANT_LIST_msg(long nodeId,long replicaHostId,long serial)
    {
        TransactionStatus s=new TransactionStatus(nodeId, serial,null,Type.IWANT_LIST,replicaHostId,null, null);
        
        //PER DEBUG
        if (s.getSerial()==null )
               throw new NullPointerException("s="+s+"; serial="+serial);
            
            //FINE PER DEBUG
            
        return s;
    }
    
    public static TransactionStatus build_HEREIS_THE_LIST_msg(
            long nodeId,Long replicaHostId,TaskList list)
    {   
        return new TransactionStatus(nodeId, list.getSerial(),null,Type.HEREIS_THE_LIST,
                replicaHostId,list, null);
    }
    
     /**
     * This ack is sent by the FrontEnd when it receives a list from a ReplicaManager during GETLIST 
     * procedure
     * @param serial : the serial of the received list
     */
    public static TransactionStatus buildAckFromFrontEnd(
            long nodeId,Operation operation)
    {
        return new TransactionStatus(nodeId,null,operation,Type.ACK,null,null);
    }

    
    
}
